<template>
  <ul class="products">
    <li v-for="item in goodsList" :key="item.id" @click="toProDetail(item.id)">
      <img :src="item.list_pic_url" alt="" />
      <div class="des van-ellipsis">{{ item.name }}</div>
      <div class="price">¥ {{ item.retail_price | priceFilter }} 元</div>
    </li>
  </ul>
</template>

<script>
export default {
  props: ["goodsList"],
  data() {
    return {};
  },
  created() {},
  mounted() {},
  methods: {
    //跳转到商品详情页
    toProDetail(val) {
      this.$router.push("/productsDetail?id=" + val);
      //这个从相关产品跳转到prodetail
      //刷新（相当于）
      if (this.$route.path.includes("/productsDetail")) {
        setTimeout(() => {
          this.$router.go(0);
        });
      }
    },
  },
};
</script>

<style scoped lang="less">
.products {
  margin-top: 0.1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin: 0.06rem;
  li {
    width: 48.5%;
    // border:1px solid red;
    background: #fff;
    text-align: center;
    margin-bottom: 0.06rem;
    padding-bottom: 0.1rem;
    img {
      width: 100%;
      height: 2rem;
    }
    .des {
      color: #333;
      line-height: 24px;
    }
    .price {
      color: darkred;
    }
  }
}
</style>
